-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add posibility to request room heroes #304
Conversation
sync3/handler/connstate_live.go
Outdated
// subscription which should return heroes. | ||
func (s *connStateLive) shouldIncludeHeroes(roomID string) bool { | ||
roomIDsToLists := s.lists.ListsByVisibleRoomIDs(s.muxedReq.Lists) | ||
subscriptionInclude := s.roomSubscriptions[roomID].IncludeHeroes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rejig this so it's faster. Checking the lists is expensive.
if s.roomSubscriptions[roomID].IncludeHeroes() {
return true
}
// rest of list checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that's easier.
@@ -263,7 +263,7 @@ func (s *connStateLive) processLiveUpdate(ctx context.Context, up caches.Update, | |||
|
|||
thisRoom.Name = roomName | |||
|
|||
if s.roomSubscriptions[roomUpdate.RoomID()].IncludeHeroes() && calculated { | |||
if calculated && s.shouldIncludeHeroes(roomUpdate.RoomID()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, but where's the tests?! :D
if !ok { | ||
return fmt.Errorf("room %q not in response", listRoomID) | ||
} | ||
// wait for bob to be joined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just use res := alice.SlidingSyncUntilMembership(t, "", listRoomID, bob, "join")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the previous test yes, but this test should use a list instead of a room subscription (used in SlidingSyncUntilMembership
)
Fixes #241
This adds a
heroes
flag toRoomSubscription
s. If the room name was calculated using room heroes, the response for the room also contains an array ofheroes
, containing theuser_id
, and optionally the fieldsdisplayname
andavatar_url
.